package ycl.system.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ycl.base.req.SysRolePermissionReq;
import ycl.common.ApiResult;
import ycl.common.base.controller.BaseController;
import ycl.common.models.base.A;
import ycl.system.entity.SysRolePermission;
import ycl.system.res.SysRolePermissionRes;
import ycl.system.service.SysRolePermissionService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * <p>
 * 角色、权限关联表 前端控制器
 * </p>
 *
 * @author ycl
 * @since 2022-03-03 11:43:57
 */
@RestController
@RequestMapping("/sys-role-permission")
@Api(tags = "角色权限")
public class SysRolePermissionController
		extends BaseController<SysRolePermission, SysRolePermissionReq, SysRolePermissionRes> {
	@Resource
	private SysRolePermissionService sysRolePermissionService;

	@Override
	public ApiResult<Page<SysRolePermissionRes>> pageList(SysRolePermission sysRolePermission) {
		return ApiResult.success(sysRolePermissionService.pageList(sysRolePermission, SysRolePermissionRes.class));
	}

	@Override
	public <E extends SysRolePermissionReq> ApiResult<A> save(HttpServletRequest request, @Valid E e) {
		sysRolePermissionService.save(request, e, SysRolePermission.class);
		return ApiResult.success();
	}

	@Override
	public <E extends SysRolePermissionReq> ApiResult<A> update(HttpServletRequest request, @Valid E e) {
		sysRolePermissionService.update(request, e, SysRolePermission.class);
		return ApiResult.success();
	}

}

